class_name Enemy
extends Character



@onready var sprite: Sprite2D = $Sprite2D
@onready var damage_sender: DamageSender = $DamageSender
@onready var navigation_agent: NavigationAgent2D = $NavigationAgent2D

# @onready var _player := get_tree().get_first_node_in_group("player") as Player



func _ready() -> void:
    damage_sender.damage_info = DamageInfo.create(
        self, null, data.attack.value, data.damage_attribute, 
        data.critical_rate.value, data.critical_degree.value,
        true, false, false, false, -1)

    navigation_agent.max_speed = data.speed.value



func _process(_delta: float) -> void:
    _face_follow_player()



func _face_follow_player() -> void:
    sprite.flip_h = true if Global.get_player().global_position.x - global_position.x < 0 else false
